package com.myecl.poker.communication;

import java.io.IOException;
import java.io.ObjectOutputStream;

import com.myecl.poker.option.Command;
import com.myecl.poker.option.CommandNoValue;
import com.myecl.poker.option.CommandValue;
import com.myecl.poker.rules.enums.Option;


public class ClientConnector {
	private final ObjectOutputStream objectOutput;
	
	public ClientConnector(ObjectOutputStream objectOutput) {
		this.objectOutput = objectOutput;
	}
	
	public void quit() {
		
	}
	
	public void fold() {
		sendCommand(new CommandNoValue(Option.FOLD));
	}
	
	public void check() {
		sendCommand(new CommandNoValue(Option.CHECK));
	}
	
	public void call(double value) {
		sendCommand(new CommandValue(Option.CALL, value));
	}
	
	public void raise(double value) {
		sendCommand(new CommandValue(Option.RAISE, value));
	}
	
	private void sendCommand(Command command) {
		try {
			objectOutput.writeObject(command);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
